/*
 * CustomerFrame.java
 *
 * Created on February 18, 2007, 9:05 PM
 */

package edu.byu.isys413.group1E.gui;

import edu.byu.isys413.group1E.*;
import edu.byu.isys413.group1E.data.*;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.*;

/**
 *
 * @author  tkulbeth
 */
public class CustomerFrame extends javax.swing.JFrame {
    
    CustomerBO cust = null;
    MainFrame mf = null;
    
    /** Creates new form CustomerFrame */
    public CustomerFrame() {
        initComponents();
        this.setFrameEnabled(false);
    }
    
    
    /** Creates new form CustomerFrame with the calling main frame, if that's what called it.
     *@param mf contains the main frame object
     */
    public CustomerFrame(MainFrame mf) {
        initComponents();
        this.mf = mf;
        this.setFrameEnabled(false);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        chkBoxes_groupNewCust = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        button_addCust = new javax.swing.JButton();
        button_searchCust = new javax.swing.JButton();
        button_viewAllCust = new javax.swing.JButton();
        button_viewAllMemb = new javax.swing.JButton();
        button_viewAll_AOI = new javax.swing.JButton();
        label_logo = new javax.swing.JLabel();
        label_taskSelect = new javax.swing.JLabel();
        label_enterData = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        field_fName = new javax.swing.JTextField();
        label_fName = new javax.swing.JLabel();
        field_MI = new javax.swing.JTextField();
        label_MI = new javax.swing.JLabel();
        field_lName = new javax.swing.JTextField();
        label_lName = new javax.swing.JLabel();
        label_Address = new javax.swing.JLabel();
        field_City = new javax.swing.JTextField();
        label_City = new javax.swing.JLabel();
        field_State = new javax.swing.JTextField();
        label_State = new javax.swing.JLabel();
        field_Zip = new javax.swing.JTextField();
        label_Zip = new javax.swing.JLabel();
        field_Phone = new javax.swing.JTextField();
        label_Phone = new javax.swing.JLabel();
        field_Email = new javax.swing.JTextField();
        label_Email = new javax.swing.JLabel();
        label_beginMember = new javax.swing.JLabel();
        chkBox_Yes = new javax.swing.JCheckBox();
        chkBox_No = new javax.swing.JCheckBox();
        button_Save = new javax.swing.JToggleButton();
        button_Cancel = new javax.swing.JToggleButton();
        field_Address = new javax.swing.JTextField();
        button_editMemb = new javax.swing.JButton();
        button_useCust = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Customer Information");
        setBounds(new java.awt.Rectangle(0, 0, 750, 300));
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 700, 300));
        setMinimumSize(new java.awt.Dimension(650, 300));
        setName("Customer Management");
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        button_addCust.setText("Add New Customer");
        button_addCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_addCustActionPerformed(evt);
            }
        });

        button_searchCust.setText("Search for Customer");
        button_searchCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_searchCustActionPerformed(evt);
            }
        });

        button_viewAllCust.setText("View Customers");
        button_viewAllCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_viewAllCustActionPerformed(evt);
            }
        });

        button_viewAllMemb.setText("View Members");
        button_viewAllMemb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_viewAllMembActionPerformed(evt);
            }
        });

        button_viewAll_AOI.setFont(new java.awt.Font("Dialog", 1, 11));
        button_viewAll_AOI.setText("View Areas of Interest");
        button_viewAll_AOI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_viewAll_AOIActionPerformed(evt);
            }
        });

        label_logo.setIcon(new javax.swing.ImageIcon("/home/tkulbeth/Programs/MyStuff_413/Logo.jpg"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(button_addCust, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE)
                            .addComponent(button_searchCust)
                            .addComponent(button_viewAllCust, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_viewAllMemb, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_viewAll_AOI, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addComponent(label_logo)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(button_addCust)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(button_searchCust)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(label_logo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
                .addComponent(button_viewAllCust)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(button_viewAllMemb)
                .addGap(5, 5, 5)
                .addComponent(button_viewAll_AOI)
                .addContainerGap())
        );

        label_taskSelect.setText("Select a Task");

        label_enterData.setText("Enter New Customer Data");

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        field_fName.setText("<First Name>");
        field_fName.setMinimumSize(new java.awt.Dimension(86, 19));
        field_fName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_fNameFocusGained(evt);
            }
        });

        label_fName.setFont(new java.awt.Font("Dialog", 1, 10));
        label_fName.setText("First Name: *");

        field_MI.setText("<MI>");
        field_MI.setAutoscrolls(false);
        field_MI.setMinimumSize(new java.awt.Dimension(37, 19));
        field_MI.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_MIFocusGained(evt);
            }
        });

        label_MI.setFont(new java.awt.Font("Dialog", 1, 10));
        label_MI.setText("M.I.");

        field_lName.setText("<Last Name>");
        field_lName.setMinimumSize(new java.awt.Dimension(85, 19));
        field_lName.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_lNameFocusGained(evt);
            }
        });

        label_lName.setFont(new java.awt.Font("Dialog", 1, 10));
        label_lName.setText("LastName: *");

        label_Address.setFont(new java.awt.Font("Dialog", 1, 10));
        label_Address.setText("Address:");

        field_City.setText("<City>");
        field_City.setMinimumSize(new java.awt.Dimension(45, 19));
        field_City.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_CityFocusGained(evt);
            }
        });

        label_City.setFont(new java.awt.Font("Dialog", 1, 10));
        label_City.setText("City:");

        field_State.setText("<ST>");
        field_State.setMinimumSize(new java.awt.Dimension(38, 19));
        field_State.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_StateFocusGained(evt);
            }
        });

        label_State.setFont(new java.awt.Font("Dialog", 1, 10));
        label_State.setText("State:");

        field_Zip.setText("<Postal Code>");
        field_Zip.setMinimumSize(new java.awt.Dimension(92, 19));
        field_Zip.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_ZipFocusGained(evt);
            }
        });

        label_Zip.setFont(new java.awt.Font("Dialog", 1, 10));
        label_Zip.setText("Postal Code:");

        field_Phone.setText("<Phone>");
        field_Phone.setMinimumSize(new java.awt.Dimension(59, 19));
        field_Phone.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_PhoneFocusGained(evt);
            }
        });

        label_Phone.setFont(new java.awt.Font("Dialog", 1, 10));
        label_Phone.setText("Phone:");

        field_Email.setText("<Email>");
        field_Email.setMinimumSize(new java.awt.Dimension(55, 19));
        field_Email.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_EmailFocusGained(evt);
            }
        });

        label_Email.setFont(new java.awt.Font("Dialog", 1, 10));
        label_Email.setText("Email:");

        label_beginMember.setFont(new java.awt.Font("Dialog", 1, 10));
        label_beginMember.setText("Begin Membership?");

        chkBoxes_groupNewCust.add(chkBox_Yes);
        chkBox_Yes.setText("Yes");
        chkBox_Yes.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkBox_Yes.setMargin(new java.awt.Insets(0, 0, 0, 0));
        chkBox_Yes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                chkBox_YesMouseClicked(evt);
            }
        });
        chkBox_Yes.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                chkBox_YesStateChanged(evt);
            }
        });

        chkBoxes_groupNewCust.add(chkBox_No);
        chkBox_No.setSelected(true);
        chkBox_No.setText("No");
        chkBox_No.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkBox_No.setMargin(new java.awt.Insets(0, 0, 0, 0));
        chkBox_No.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                chkBox_NoStateChanged(evt);
            }
        });

        button_Save.setText("Save");
        button_Save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_SaveActionPerformed(evt);
            }
        });

        button_Cancel.setText("Cancel");
        button_Cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_CancelActionPerformed(evt);
            }
        });

        field_Address.setText("<Address>");
        field_Address.setMinimumSize(new java.awt.Dimension(72, 19));
        field_Address.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                field_AddressFocusGained(evt);
            }
        });

        button_editMemb.setFont(new java.awt.Font("Dialog", 0, 10));
        button_editMemb.setText("View/Edit Membership");
        button_editMemb.setEnabled(false);
        button_editMemb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_editMembActionPerformed(evt);
            }
        });

        button_useCust.setText("Use for Tx");
        button_useCust.setEnabled(false);
        button_useCust.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_useCustActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_taskSelect)
                        .addGap(122, 122, 122))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)))
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(label_Address, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_Email, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(field_City, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_City))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(field_State, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_State))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(field_Zip, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_Zip))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_Phone)
                                .addGap(82, 82, 82))
                            .addComponent(field_Phone, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)))
                    .addComponent(label_enterData, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(button_useCust)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(button_Save, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(button_Cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(field_Email, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label_beginMember)))
                        .addGap(39, 39, 39)
                        .addComponent(chkBox_Yes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chkBox_No))
                    .addComponent(button_editMemb)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_fName)
                            .addComponent(field_fName, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addComponent(field_MI, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(label_MI))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(label_lName)
                                .addGap(127, 127, 127))
                            .addComponent(field_lName, javax.swing.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)))
                    .addComponent(field_Address, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {button_Cancel, button_Save});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(label_enterData)
                    .addComponent(label_taskSelect))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(label_fName)
                            .addComponent(label_MI)
                            .addComponent(label_lName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(field_MI, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(field_fName, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(field_lName, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label_Address)
                        .addGap(3, 3, 3)
                        .addComponent(field_Address, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(label_City)
                            .addComponent(label_State)
                            .addComponent(label_Zip)
                            .addComponent(label_Phone))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(field_Zip, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(field_State, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(field_City, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(label_Email))
                            .addComponent(field_Phone, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(field_Email, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_beginMember)
                            .addComponent(chkBox_Yes)
                            .addComponent(chkBox_No))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(button_editMemb)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(button_Save, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_Cancel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_useCust))))
                .addGap(24, 24, 24))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void button_useCustActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_useCustActionPerformed
        if(this.mf != null){
            mf.setCust(this.cust);
            this.setVisible(false);
            this.dispose();
        }
    }//GEN-LAST:event_button_useCustActionPerformed
    
    private void button_viewAll_AOIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_viewAll_AOIActionPerformed
        try {
            String look = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(look);
            String blank = null;
            AreaOfInterestFrame aoiFrame = new AreaOfInterestFrame(this);
            aoiFrame.setLocationRelativeTo(null);
            aoiFrame.setVisible(true);
        }catch(Exception e){
            e.printStackTrace();
        }
        
    }//GEN-LAST:event_button_viewAll_AOIActionPerformed
    
    private void button_viewAllMembActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_viewAllMembActionPerformed
        try {
            String look = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(look);
            String blank = null;
            SelectFrame searchList = new SelectFrame(CustomerDAO.getInstance().searchCust(blank,blank,
                    blank,blank,blank,blank,blank,blank,blank,true), this);      //initialize frame
            searchList.setLocationRelativeTo(null);                                       //set frame location to center of screen
            searchList.setVisible(true);                                                  //display frame
            button_Save.setSelected(false);
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (DataException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ConnectionPoolException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_button_viewAllMembActionPerformed
    
    private void button_viewAllCustActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_viewAllCustActionPerformed
        try {
            String look = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(look);
            SelectFrame searchList = new SelectFrame(CustomerDAO.getInstance().readAllCust(), this);      //initialize frame
            searchList.setLocationRelativeTo(null);                                       //set frame location to center of screen
            searchList.setVisible(true);                                                  //display frame
            button_Save.setSelected(false);
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (DataException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ConnectionPoolException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_button_viewAllCustActionPerformed
    
    private void button_editMembActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_editMembActionPerformed
        try {                                                           //change appearance according to system
            String look = UIManager.getSystemLookAndFeelClassName();
            UIManager.setLookAndFeel(look);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        MembershipFrame memberFrame = new MembershipFrame(cust, this);                           //initialize frame
        memberFrame.setLocationRelativeTo(null);                                       //set frame location to center of screen
        memberFrame.setVisible(true);                                                  //display frame
    }//GEN-LAST:event_button_editMembActionPerformed
    
    private void button_searchCustActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_searchCustActionPerformed
        this.label_enterData.setText("Enter Search Criteria:");
        this.button_Save.setText("Search");
        this.label_beginMember.setText("Is Member?");
        this.button_searchCust.setSelected(false);
        this.setFrameEnabled(true);
        this.button_editMemb.setEnabled(false);
        this.resetFrame();
    }//GEN-LAST:event_button_searchCustActionPerformed
    
    private void button_addCustActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_addCustActionPerformed
        this.label_enterData.setText("Enter New Customer Data");
        this.label_beginMember.setText("Begin Membership?");
        this.button_Save.setText("Save");
        this.button_addCust.setSelected(false);
        try {
            cust = CustomerDAO.getInstance().create();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        this.setFrameEnabled(true);
        this.button_editMemb.setEnabled(false);
        this.resetFrame();
    }//GEN-LAST:event_button_addCustActionPerformed
    
    private void button_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_CancelActionPerformed
        int opt = JOptionPane.showConfirmDialog(null,"Are you sure you want to cancel?","Cancel Warning", JOptionPane.YES_NO_OPTION);
        if(opt == JOptionPane.YES_OPTION){
            this.resetFrame();
            cust = null;
            this.setFrameEnabled(false);
            return;
        }else{
            button_Cancel.setSelected(false);
            return;
        }
    }//GEN-LAST:event_button_CancelActionPerformed
    
    private void button_SaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_SaveActionPerformed
        /*actions if the button is for 'Save'*/
        if(button_Save.getText().equals("Save")){
            //if the first name and last name (the two required fields) are not filled in, request them
            if(field_fName.getText().equals("") || field_fName.getText().equals("<First Name>") ||
                    field_lName.getText().equals("") || field_lName.getText().equals("<Last Name>")){
                JOptionPane.showMessageDialog(null,"Please fill out the First and Last Name fields.");
                button_Save.setSelected(false);
                return;
            }else{
                //when the 'Save' button is clicked
                int opt = JOptionPane.showConfirmDialog(null,"Save Customer to the database?","Save?", JOptionPane.YES_NO_OPTION);
                if( opt == JOptionPane.YES_OPTION){
                    try{
                        if(cust == null){
                            cust = CustomerDAO.getInstance().create();
                        }
                        
                        //set the values of the object according to UI input if input was entered
                        cust.setIsDirty(true);
                        cust.setCustFirstName(field_fName.getText());
                        if(!field_MI.getText().equals("<MI>")){cust.setCustMI(field_MI.getText());}
                        cust.setCustLastName(field_lName.getText());
                        if(!field_Address.getText().equals("<Address>")){cust.setCustAddr(field_Address.getText());}
                        if(!field_City.getText().equals("<City>")){cust.setCustCity(field_City.getText());}
                        if(!field_State.getText().equals("<ST>")){cust.setCustState(field_State.getText());}
                        if(!field_Zip.getText().equals("<Postal Code>")){cust.setCustZip(field_Zip.getText());}
                        if(!field_Phone.getText().equals("<Phone>")){cust.setCustPhone(field_Phone.getText());}
                        if(!field_Email.getText().equals("<Email>")){cust.setCustEmail(field_Email.getText());}
                        
                        //save the customer object to the DB
                        CustomerDAO.getInstance().save(cust);
                        
                        //if the customer opted to become a member, bring up the Membership Frame
                        if(chkBox_Yes.isSelected() == true){
                            try {                                                                           //change appearance according to system
                                String look = UIManager.getSystemLookAndFeelClassName();
                                UIManager.setLookAndFeel(look);
                            } catch (Exception ex) {
                                ex.printStackTrace();
                            }
                            MembershipFrame memberFrame = new MembershipFrame(cust, this);                           //initialize frame
                            memberFrame.setLocationRelativeTo(null);                                       //set frame location to center of screen
                            memberFrame.setVisible(true);                                                  //display frame
                        }else{
                            JOptionPane.showMessageDialog(null,"Customer saved to database Successfully.");
                            resetFrame();
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    button_Save.setSelected(false);
                    return;
                }else{
                    return;
                }
            }
        }else if(button_Save.getText().equals("Search")){       //Actions if the button is to search
            try {                                                                           //change appearance according to system
                String look = UIManager.getSystemLookAndFeelClassName();
                UIManager.setLookAndFeel(look);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            SelectFrame searchList = new SelectFrame(search(), this);      //initialize frame
            searchList.setLocationRelativeTo(null);                                       //set frame location to center of screen
            searchList.setVisible(true);                                                  //display frame
            button_Save.setSelected(false);
        }
    }//GEN-LAST:event_button_SaveActionPerformed
    
    /*method to search for designated criteria*/
    public synchronized ArrayList<CustomerBO> search(){
        String fname = null, mi = null, lname = null, addr = null, city = null, state = null, zip = null, phone = null, email = null;
        if(!field_fName.getText().equals("<First Name>") && !field_fName.getText().equals("")) fname = field_fName.getText();
        if(!field_MI.getText().equals("<MI>") && !field_MI.getText().equals("")) mi = field_MI.getText();
        if(!field_lName.getText().equals("<Last Name>") && !field_lName.getText().equals("")) lname = field_lName.getText();
        if(!field_Address.getText().equals("<Address>") && !field_Address.getText().equals("")) addr = field_Address.getText();
        if(!field_City.getText().equals("<City>") && !field_City.getText().equals("")) city = field_City.getText();
        if(!field_State.getText().equals("<ST>") && !field_State.getText().equals("")) state = field_State.getText();
        if(!field_Zip.getText().equals("<Postal Code>") && !field_Zip.getText().equals("")) zip = field_Zip.getText();
        if(!field_Phone.getText().equals("<Phone>") && !field_Phone.getText().equals("")) phone = field_Phone.getText();
        if(!field_Email.getText().equals("<Email>") && !field_Email.getText().equals("")) email = field_Email.getText();
        try {
            return CustomerDAO.getInstance().searchCust(fname, mi, lname, addr, city, state, zip, phone, email, chkBox_Yes.isSelected());
        } catch (ConnectionPoolException ex) {
            ex.printStackTrace();
        } catch (DataException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return null;
    }
    
    
    private void chkBox_NoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_chkBox_NoStateChanged
        if(chkBox_No.isSelected()){chkBox_Yes.setSelected(false);}              //when this one is selected, deselect the 'No' option
    }//GEN-LAST:event_chkBox_NoStateChanged
    
    private void chkBox_YesStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_chkBox_YesStateChanged
        if(chkBox_Yes.isSelected()){chkBox_No.setSelected(false);}              //when this one is selected, deselect the 'No' option
    }//GEN-LAST:event_chkBox_YesStateChanged
    
    private void chkBox_YesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chkBox_YesMouseClicked
// TODO add your handling code here:
    }//GEN-LAST:event_chkBox_YesMouseClicked
    
    private void field_EmailFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_EmailFocusGained
        if(field_Email.getText().equals("<Email>")){ field_Email.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_EmailFocusGained
    
    private void field_PhoneFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_PhoneFocusGained
        if(field_Phone.getText().equals("<Phone>")){ field_Phone.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_PhoneFocusGained
    
    private void field_ZipFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_ZipFocusGained
        if(field_Zip.getText().equals("<Postal Code>")){ field_Zip.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_ZipFocusGained
    
    private void field_StateFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_StateFocusGained
        if(field_State.getText().equals("<ST>")){ field_State.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_StateFocusGained
    
    private void field_CityFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_CityFocusGained
        if(field_City.getText().equals("<City>")){ field_City.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_CityFocusGained
    
    private void field_AddressFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_AddressFocusGained
        if(field_Address.getText().equals("<Address>")){ field_Address.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_AddressFocusGained
    
    private void field_lNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_lNameFocusGained
        if(field_lName.getText().equals("<Last Name>")){ field_lName.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_lNameFocusGained
    
    private void field_MIFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_MIFocusGained
        if(field_MI.getText().equals("<MI>")){ field_MI.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_MIFocusGained
    
    private void field_fNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_field_fNameFocusGained
        if(field_fName.getText().equals("<First Name>")){ field_fName.setText(""); }           //set the field text to blank for user input
    }//GEN-LAST:event_field_fNameFocusGained
    
    public void setCust(CustomerBO custIn){
        this.cust = custIn;
        this.cust.setAlreadyInDB(true);
        this.field_fName.setText(cust.getCustFirstName());
        this.field_MI.setText(cust.getCustMI());
        this.field_lName.setText(cust.getCustLastName());
        this.field_Address.setText(cust.getCustAddr());
        this.field_City.setText(cust.getCustCity());
        this.field_State.setText(cust.getCustState());
        this.field_Zip.setText(cust.getCustZip());
        this.field_Phone.setText(cust.getCustPhone());
        this.field_Email.setText(cust.getCustEmail());
        this.button_useCust.setEnabled(true);
        if(cust.getCustMembership() != null){
            this.chkBox_Yes.setSelected(true);
            this.chkBox_No.setSelected(false);
            this.button_editMemb.setEnabled(true);
        }
    }
    
    /*set the text of the save button*/
    public void setButton_UseCust(boolean is){
        this.button_useCust.setEnabled(is);
    }
    
    /*set the text of the save button*/
    public void setButton_SaveText(String text){
        this.button_Save.setText(text);
    }
    
    /*set the text of the save button*/
    public void setButton_EditMembState(boolean state){
        this.button_editMemb.setEnabled(state);
    }
    
    /*set the text of the No check box*/
    public void setChkBox_NoState(boolean state){
        this.chkBox_No.setSelected(state);
    }
    
    /*set the text of the yes check box*/
    public void setChkBox_YesState(boolean state){
        this.chkBox_Yes.setSelected(state);
    }
    
    /*set the No check box to disabled for members*/
    public void setChkBox_NoEnabled(boolean state){
        this.chkBox_No.setEnabled(state);
    }
    
    /*set the text of the top*/
    public void setLabel_EnterDataText(String text){
        this.label_enterData.setText(text);
    }
    
    /*set the text of the membership label*/
    public void setLabel_memberText(String text){
        this.label_beginMember.setText(text);
    }
    
    
    /*resets the contents of the Frame to default*/
    private void resetFrame(){
        field_fName.setText("<First Name>");
        field_MI.setText("<MI>");
        field_lName.setText("<Last Name>");
        field_Address.setText("<Address>");
        field_City.setText("<City>");
        field_State.setText("<ST>");
        field_Zip.setText("<Postal Code>");
        field_Phone.setText("<Phone>");
        field_Email.setText("<Email>");
        button_Cancel.setSelected(false);
        button_Save.setSelected(false);
        button_editMemb.setSelected(false);
        return;
    }
    
    /*resets the contents of the Frame to default*/
    public void setFrameEnabled(boolean state){
        field_fName.setEnabled(state);
        field_MI.setEnabled(state);
        field_lName.setEnabled(state);
        field_Address.setEnabled(state);
        field_City.setEnabled(state);
        field_State.setEnabled(state);
        field_Zip.setEnabled(state);
        field_Phone.setEnabled(state);
        field_Email.setEnabled(state);
        button_Cancel.setEnabled(state);
        button_Save.setEnabled(state);
        button_editMemb.setEnabled(state);
        chkBox_Yes.setEnabled(state);
        chkBox_No.setEnabled(state);
        return;
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CustomerFrame().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton button_Cancel;
    private javax.swing.JToggleButton button_Save;
    private javax.swing.JButton button_addCust;
    private javax.swing.JButton button_editMemb;
    private javax.swing.JButton button_searchCust;
    private javax.swing.JButton button_useCust;
    private javax.swing.JButton button_viewAllCust;
    private javax.swing.JButton button_viewAllMemb;
    private javax.swing.JButton button_viewAll_AOI;
    private javax.swing.JCheckBox chkBox_No;
    private javax.swing.JCheckBox chkBox_Yes;
    private javax.swing.ButtonGroup chkBoxes_groupNewCust;
    private javax.swing.JTextField field_Address;
    private javax.swing.JTextField field_City;
    private javax.swing.JTextField field_Email;
    private javax.swing.JTextField field_MI;
    private javax.swing.JTextField field_Phone;
    private javax.swing.JTextField field_State;
    private javax.swing.JTextField field_Zip;
    private javax.swing.JTextField field_fName;
    private javax.swing.JTextField field_lName;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel label_Address;
    private javax.swing.JLabel label_City;
    private javax.swing.JLabel label_Email;
    private javax.swing.JLabel label_MI;
    private javax.swing.JLabel label_Phone;
    private javax.swing.JLabel label_State;
    private javax.swing.JLabel label_Zip;
    private javax.swing.JLabel label_beginMember;
    private javax.swing.JLabel label_enterData;
    private javax.swing.JLabel label_fName;
    private javax.swing.JLabel label_lName;
    private javax.swing.JLabel label_logo;
    private javax.swing.JLabel label_taskSelect;
    // End of variables declaration//GEN-END:variables
    
}
